<%@ page import="javax.xml.crypto.Data" %>
<%@ page import="java.util.*" %>
<%@ page import="com.mfp.java.testYou.core.AppContext" %>
<%@ page import="com.mfp.java.testYou.ui.mvc.DetailedResultPage" %>
<%@ taglib prefix="testU" uri="testYou" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="../global/global.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <jsp:include page="../components/htmlHeader.jsp"></jsp:include>
    <title><testU:i18n>result.title</testU:i18n></title>
    <script language="JavaScript" src="<%=cPath%>/testYou/resources/table.js">
    </script>
</head>
<body class="bgColor textColor">
<jsp:include page="../components/header.jsp"/>


<c:set var="idLog" value="<%=AppContext.getUserSession(request)%>"/>
<c:set var="resPage" value="<%=new DetailedResultPage(request, response)%>"/>

<table class="results table-autosort:0 table-autostripe table-stripeclass:alternate padTop5 centerTable30marg width40">
    <thead>
    <tr class="height40px">
        <th class="table-filterable table-sortable:text table-sortable table-sorted-desc" title="Click to sort">
            <testU:i18n>results.name</testU:i18n>
        </th>
        <th class="table-filterable table-sortable:text table-sortable table-sorted-desc" title="Click to sort">
            <testU:i18n>results.testType</testU:i18n>
        </th>
        <th class="table-sortable:numeric table-sortable" title="Click to sort">
            <testU:i18n>results.score</testU:i18n></th>
        <th class="table-sortable:date table-sortable" title="Click to sort"><testU:i18n>results.date</testU:i18n></th>
    </tr>
    <tr>
        <th><input name="filter" size="10" onkeyup="Table.filter(this,this)"></th>
        <th><input name="filter" size="10" onkeyup="Table.filter(this,this)"></th>
        <th>
            <select title="s1" onchange="Table.filter(this,this)">
                <option value="function(){return true;}">All</option>
                <option value="function(val){return val >4;}">&gt; 4</option>
                <option value="function(val){return val <=4 ;}">&lt;= 4</option>
            </select>

            <select title="s2" onchange="Table.filter(this,this)">
                <option value="">All</option>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
                <option value="9">9</option>
                <option value="10">10</option>
            </select>
        </th>
        <th>
            <input name="filter" size="13" onkeyup="Table.filter(this,this)" value="YYYY-MM-DD"/></th>
        </th>
    </tr>
    </thead>
    <tbody class="alignCenter">
    <testU:studentOnly>
        <c:forEach var="item" items="${resPage.usersResultsList}">
            <c:if test="${idLog.userName == item.userName}">
                <tr>
                    <td>${idLog.userName}</td>
                    <td>${item.title}</td>
                    <td><fmt:formatNumber value="${item.result}" maxFractionDigits="2"/></td>
                    <td><fmt:formatDate value="${item.date}" pattern="yyyy-MM-dd"/></td>
                </tr>
            </c:if>

        </c:forEach>
    </testU:studentOnly>

    <testU:adminOnly>
        <c:forEach var="item" items="${resPage.usersResultsList}">
            <tr>
                <td>${item.userName}</td>
                <td>${item.title}</td>
                <td><fmt:formatNumber value="${item.result}" maxFractionDigits="2"/></td>
                <td><fmt:formatDate value="${item.date}" pattern="yyyy-MM-dd"/></td>
            </tr>
        </c:forEach>
    </testU:adminOnly>
    </tbody>
</table>
<table class="centerTable30marg width40 padTop3">
    <tbody>
    <tr>
        <td class="alignCenter"><input class="width80px" type="button" value="<testU:i18n>button.back</testU:i18n>"
                                       onclick="window.location.href='<%=cPath%>/testYou/pages/userMenu.jsp'"/>
        </td>
    </tr>
    </tbody>
</table>

</body>
</html>